package cn.jbit.ams.order.biz.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.jbit.ams.mainperson.dao.MainpersonMapper;
import cn.jbit.ams.order.biz.OrderService;
import cn.jbit.ams.order.dao.OrderMapper;
import cn.jbit.ams.user.pojo.Order;
import cn.jbit.ams.user.pojo.Productinfo;

@Service
@Transactional
public class OrderServiceImpl implements OrderService{

	@Autowired
	OrderMapper orderMapper;


	@Override
	public Page<Order> findOrder(Integer pageNum) {
		if(pageNum==null) {
			pageNum=1;
		}
		Page<Order> orderPage=PageHelper.startPage(pageNum,3);
		orderMapper.findOrder();
		return orderPage;
	}


	@Override
	public List<Order> getOrder(Integer mId) {
		// TODO Auto-generated method stub
		return orderMapper.getOrder(mId);
	}


	@Override
	public int deleteOrder(Integer mId) {
		try {
			orderMapper.deleteOrder(mId);
			return 1;
		} catch (Exception e) {
			System.out.println("删除订单信息失败");
			System.out.println(e);
			return 0;
		}

	}

	@Override
	public List<Order> getOrderTime() {
		// TODO Auto-generated method stub
		return orderMapper.getOrderTime();
	}

	@Override
	public List<Order> select(String id) {
		// TODO Auto-generated method stub
		return orderMapper.select(id);
	}

	@Override 
	public void update(int mid, int oid) {
		// TODO Auto-generated method stub

		orderMapper.update(mid, oid);
	}

	@Override
	public void paigong(String oid, String mid) {
		// TODO Auto-generated method stub
		orderMapper.paigong(oid, mid);
	}


	@Override
	public void orderOk() {
		try {
			orderMapper.orderOk();
		} catch (Exception e) {
			System.out.println(e);
		}
	}


	@Override
	public Productinfo getOneInfo(Integer productInfoId) {
		// TODO Auto-generated method stub
		return orderMapper.getOneInfo(productInfoId);
	}


	@Override
	public Page<Order> getoptionOrder(Integer state,Integer pageNum) {
		if(pageNum==null) {
			pageNum=1;
		}
		Page<Order> orderPage=PageHelper.startPage(pageNum,3);
		orderMapper.getoptionOrder(state);
		return orderPage;
	}
}
